from django.db import models


# Create your models here.

# 多对多
# 作者  author
class Author(models.Model):
    name = models.CharField(max_length=50)
    age = models.IntegerField()

    class Meta:
        db_table = 'author'


# 书籍  book
class Book(models.Model):
    title = models.CharField(max_length=50)
    price = models.IntegerField()
    #  author  book 构建多对多的数据关系
    authors = models.ManyToManyField(Author)

    class Meta:
        db_table = 'bok'


"""
  多对多的数据迁移 
  table   
    1. author     1   2
    2. book       1   2   3
    3. book_author  关系表  
       id  author_id  book_id 
        1      1          1
        2      1          2
        3      1          3
        4      2          3
        5      2          1
"""
